<?php 
if (!isset($instance['category'])){
	$instance['category'] = 0;
}
extract($instance);
global $wpdb;
global $post;
 do_action( 'before' ); 
 if ( (in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) || (in_array( 'jigoshop/jigoshop.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ))) ) { 
if($category != 0)
{
 $default = array(
	'post_type' => 'product',
	'tax_query'	=> array(
	array(
		'taxonomy'	=> 'product_cat',
		'field'		=> 'id',
		'terms'		=> $category)),
	'orderby' => $orderby,
	'order' => $order,
	'post_status' => 'publish',
	'showposts' => $numberposts
);
}
else{
 $default = array(
	'post_type' => 'product',
	'orderby' => $orderby,
	'order' => $order,
	'post_status' => 'publish',
	'showposts' => $numberposts
);
}


$loop = new WP_Query($default);
if ($loop->have_posts()){
$i = 0;
$j = 0;
?>
<div id="<?php echo $widget_id; ?>" class="sidebar-product-slider carousel slide">
	<div class="carousel-inner">	
			<?php while( $loop->have_posts() ) : $loop->the_post(); global $product, $post; ?>
			<div class="item <?php if( $i == 0 ){ echo 'active'; } ?>">
				<div class="item-inner">
					<?php if( has_post_thumbnail() ){ ?>
					<div class="item-image">
						<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('shop-catalog'); ?> </a>
					</div>
					<?php } ?>
					<div class="item-content">
						<div class="item-title">
							<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
						</div>
						<div class="item-price">
							<?php echo $product->get_price_html(); ?>
						</div>
						<div class="item-description">
							<?php echo $content = self::ya_trim_words($post->post_excerpt, 15, ' ');?>
						</div>
					</div>
				</div>
			</div>
		<?php  $i++; endwhile; wp_reset_query(); ?>
	</div>
	<div class="product-nav">
		<a class="button-prev pull-left" href="#<?php echo $widget_id; ?>" data-slide="prev" class=""><i class="icon-circle-arrow-left"></i></a>
		<ul class="nav-page carousel-indicators">
			<?php while( $loop->have_posts() ) : $loop->the_post(); ?>
				<li data-target="#<?php echo $widget_id; ?>" data-slide-to="<?php echo $j; ?>" class="<?php if( $j == 0 ){echo 'active'; } ?>"></li>
			<?php $j++; endwhile; wp_reset_query(); ?>
		</ul>
		<a class="button-next pull-right" href="#<?php echo $widget_id; ?>" data-slide="next" class=""><i class="icon-circle-arrow-right"></i></a>
	</div>
</div>
<?php } }?>